<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>收入记录</title>
	<link href="../css/public.css" rel="stylesheet"/>
	<link href="../css/main.css" rel="stylesheet"/>
	<link href="../css/style.css" rel="stylesheet"/>
	<link href="../css/agent.css?v=11" rel="stylesheet"/>

	<script src="./js/jquery-1.9.1.js"></script>

	<script src="../js/swiper.min.js"></script>
	<script src="../js/mobile-util.js"></script>
	<script src="../js/public.js"></script>
	<script src="../js/layer/layui.js"></script>
	<script src="../js/jquery.cookie.js"></script>

	<style>
		.deviceboxinconme{
			background: #EFEFEF!important;
		}
		.deviceboxinconme div{
			padding: .5rem 0;
			font-weight: 600;
		}
		#deinconme div{
			padding: .5rem 0;
		}
	</style>

	<script>
		/*获取url参数*/
		function getUrlParam(name) {
			var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
			var r = window.location.search.substr(1).match(reg);  //匹配目标参数
			if (r != null) return unescape(r[2]); return null; //返回参数值
		}

		/*获取url参数end*/
	</script>

</head>
<body >

<header class="mui-bar mui-bar-nav indexheader bluebg flex">
	<div class="headerlogo" onclick="back()">
		<i class="iconfont backbtn">&#xe602;</i>
	</div>

	<div class="headertitle">
		<p>收入记录</p>
	</div>

	<div class="headerright timeright hide">
		<p class="timepbox iconfont">&#xe6d9;</p>
	</div>

</header>

<main class="agentbox">

	<div class="incomede">
		<div class="deviceboxinconme flex">
			<div class="flex-1 te-ce">总收入</div>
			<div class="flex-1 te-ce">已结算</div>
			<div class="flex-1 te-ce">未结算</div>
		</div>

		<div class="flex" id="deinconme">

		</div>
	</div>


	<div class="devicebox">

		<!--设备总数-->
		<div class="devicelistbox" id="total">
			<div class="flex devicehead ba-gray">
				<div class="wi15">年月</div>
				<div class="wi25">金额</div>
				<div class="wi30">结算状态</div>
				<div class="wi30">结算时间</div>
			</div>

			<div class="nulldecice">
				<p class="iconfont ">&#xe6ed;</p>
				<p class="nulldevicetitle">您还没有收益记录</p>
			</div>

			<div class="deviceinfo">
				<!--<div class="flex devicelist">-->
					<!--<div class="flex-1">-->
						<!--1111111-->
					<!--</div>-->
					<!--<div class="flex-1">-->
						<!--三个月包月套餐-->
					<!--</div>-->
					<!--<div class="flex-1">-->
						<!--100-->
					<!--</div>-->
					<!--<div class="flex-1">-->
						<!--2018-1-1-->
					<!--</div>-->
				<!--</div>-->


			</div>

			<div class="businessmore hide" onclick="ajax_income_submit()" >
				<p>查看等多</p>
				<p class="companyicon businessmoreicon">
					<i class="iconfont comicon">&#xe624;</i>
				</p>
			</div>

		</div>

		<!--设备总数end-->




	</div>



</main>



<script>


	var tooken=$.cookie("tooken");


	if(tooken==null||tooken==undefined||tooken==""){

		window.location.href="../agent/login.html";

	}else {
		var name=$.cookie("tooken");
		var page=1;

		var url="http://wifi.qianlh.com";
		//var url="http://192.168.0.132:69";
		var geturl=url+ "/Admin/agentapi/monthMoneyList?tooken="+name+"&page=1&limit=5";

		$.ajax({
			type: 'get',
			dataType: "json",
			url: geturl,
			success: function (data) {
				//console.log(data);
				var suc=data.success;
				if(suc.code == 4007){
					alert(suc.message);
					//window.location.href="login.html";
				}else if(suc.code == 4011) {
					alert(suc.message);
					//window.location.href = "login.html";
				}else if(suc.code == 4000){
					var monthMoneyList=data.monthMoneyList;
					var str="";


					var money=data.money;
					var mostr="";

					var num=parseFloat(money.most-money.check);
					notmoney = parseFloat(num.toFixed(2));


					mostr='<div class="flex-1 te-ce">&yen '+ money.most +'</div>'+
							'<div class="flex-1 te-ce">&yen '+ money.check +'</div>'+
							'<div class="flex-1 te-ce co-blue" onclick="window.location.href=\'../levelagent/levelmynullmonthincome.html\' ">&yen '+ notmoney +'</div>';

					$('#deinconme').html(mostr);


					if(monthMoneyList.length == 0){
						$('.nulldecice').show();
						return false;
					}

					if(monthMoneyList.length > 3){
						$('.businessmore').removeClass("hide");
					}

					for(var i=0;i<monthMoneyList.length;i++){
						str+='<div class="flex devicelist" onclick="monthicon('+ monthMoneyList[i].settlementdate +')">' +
								'<div class=" wi15 co-blue">' +
								''+monthMoneyList[i].settlementdate+'' +
								'</div>' +
								'<div class="wi25 co-blue">' +
								''+monthMoneyList[i].money+'' +
								'</div>' +
								'<div class="wi30">' +
								'已结算' +
								'</div>' +
								'<div class="wi30">' +
								''+monthMoneyList[i].addtime+'' +
								'</div>' +
								'</div>'
					}


					$('.deviceinfo').html(str);
					$('.nulldecice').hide();

				}


			},error:function(data){
				alert("请检查您的网络");
			}
		});


		function ajax_income_submit() {

			page += 1;

			//console.log(page);
			$.ajax({
				type : "GET",
				dataType: "json",
				url:url + "/Admin/agentapi/commissionList?tooken="+name+"&page="+page,
				success: function(data) {

					var monthMoneyList=data.commissionList;


					if(monthMoneyList.length == 0){
						layui.use('layer', function(){
							var layer = layui.layer;

							layer.msg('没有更多数据了');
						});

					}else{

						var str="";
						for(var i=0;i<monthMoneyList.length;i++){

							str+='<div class="flex devicelist" onclick="monthicon('+ monthMoneyList[i].settlementdate +')">' +
								'<div class=" wi15">' +
								''+monthMoneyList[i].settlementdate+'' +
								'</div>' +
								'<div class="wi25">' +
								''+monthMoneyList[i].money+'' +
								'</div>' +
								'<div class="wi30">' +
								'已结算' +
								'</div>' +
								'<div class="wi35">' +
								''+monthMoneyList[i].addtime+'' +
								'</div>' +
								'</div>'

						}


						$(".deviceinfo").append(str);

					}
				}
			});
		}

		function monthicon(e) {
			window.location.href='mymonthincome.html?month='+e;
		}

	}




</script>

</body>
</html>
